package com.wsc.juc_001.c_010;



/**
 *  * 例子：父子类继承关系。父类有syn修饰的方法，而子类继承父类也同时有syn方法，但是如果不可以重入的话，那么父类调子类将会死锁
 *  * 继承类锁的是同一个对象
 */
public class Synchronized_10 {

    public synchronized void m1(){

        System.out.println(Thread.currentThread().getName() +"m1 start");
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName()+ "m1 end");
    }



    public static void main(String[] args) {
        Synchronized_10 synchronized_10 = new Synchronized_10();
        synchronized_10.m1();
    }
}

class t1 extends Synchronized_10{
    @Override
    public synchronized void m1() {
        System.out.println(Thread.currentThread().getName()+"m2 start");
        super.m1();
        System.out.println(Thread.currentThread().getName()+"m2 end");
    }
}